﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace DeliveryRoomStatusBulletin
{
    public enum ProcessStage
    {
        Stage1,
        Stage2,
        Stage3
    }

    class ProcessStageHelper : DependencyObject
    {
        public static readonly DependencyProperty ProcessCompletionProperty = DependencyProperty.RegisterAttached("ProcessCompletion", typeof(int), typeof(ProcessStageHelper), new PropertyMetadata(0, OnProcessCompletionChanged));
        private static readonly DependencyPropertyKey ProcessStagePropertyKey = DependencyProperty.RegisterAttachedReadOnly("ProcessStage",typeof(ProcessStage),typeof(ProcessStageHelper),new PropertyMetadata(ProcessStage.Stage1));
        public static readonly DependencyProperty ProcessStageProperty = ProcessStagePropertyKey.DependencyProperty;
       
        private static void OnProcessCompletionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            int progress = (int)e.NewValue;
            ProgressBar bar = d as ProgressBar;
            if (progress == 1)
            {
                bar.SetValue(ProcessStagePropertyKey, ProcessStage.Stage1);
            }
            if (progress == 2)
            {
                bar.SetValue(ProcessStagePropertyKey, ProcessStage.Stage2);
            }
            if (progress == 3)
            {
                bar.SetValue(ProcessStagePropertyKey, ProcessStage.Stage3);
            }
        }

        public static void SetProcessCompletion(ProgressBar bar, int progress)
        {
            bar.SetValue(ProcessCompletionProperty, progress);
        }

        public static void SetProcessStage(ProgressBar bar, ProcessStage stage)
        {
            bar.SetValue(ProcessStagePropertyKey, stage);
        }
    }
}
